/**
 * Created by Administrator on 2016/6/1.
 */
public class TouBao {

    public static Integer CISHU = 1000000;//模拟多少人去赌博
    public static Integer winShu = 0;
    public static Integer shuShu = 0;
    public static Integer zouQianShu = 2500;//赢够多少钱就走

    public static void main(String[] args) {

        java.util.Random random = new java.util.Random();// 定义随机类
        Integer s1 = 0;
        Integer s2 = 0;
        Integer s3 = 0;

        for (int k = 0; k < CISHU; k++) {
            Man man = new Man();
            man.setXiaZhuQian(man.getXiaZhu());
            man.setMax(man.getBenJin());
            man.setShouTouQian(man.getBenJin());

            for (; ; ) {
                //扔骰子
                s1 = random.nextInt(6) + 1;
                s2 = random.nextInt(6) + 1;
                s3 = random.nextInt(6) + 1;

                //赢的规则
                if ((s1 + s2 + s3) >= 4 && (s1 + s2 + s3) <= 10) {
                    //赢后做的事情
                    man.setJuShu(man.getJuShu() + 1);
                    man.setMax(man.getMax() + man.getXiaZhu());
                    man.setShouTouQian(man.getShouTouQian() + man.getXiaZhuQian());
                    man.setXiaZhuQian(man.getXiaZhu());
                    //大于多少钱就走
                    if (man.getShouTouQian() >= zouQianShu) {
                        break;
                    }
                } else {
                    //输后做的事情
                    man.setJuShu(man.getJuShu() + 1);
                    man.setShouTouQian(man.getShouTouQian() - man.getXiaZhuQian());
                    man.setXiaZhuQian(man.getXiaZhuQian() * 2);
//                   如果手头的钱不够下次下注也算输
                    if (man.getShouTouQian() < man.getXiaZhuQian()) {
                        break;
                    }
                }
            }

            if (man.getShouTouQian() < man.getBenJin()) {
                shuShu++;
                System.out.println("输钱了!手头还有[" + man.getShouTouQian() + "]钱，共玩了[" + man.getJuShu() + "]局????");
            } else {
                winShu++;
                System.out.println("赢钱了！赢了[" + man.getMax() + "]元钱!共玩了[" + man.getJuShu() + "]局!!!!");
            }
        }

        System.out.println("共赢多少人：" + winShu);
        System.out.println("共输多少人：" + shuShu);
    }
}
